package com.stockz.equity.indicator.vsa.property;

import java.util.List;

import com.stockz.equity.indicator.vsa.VsaBar;
import com.stockz.equity.model.Bar;

public class AverageTradeSize extends RangeEnum {
	public static final AverageTradeSize Climatic = new AverageTradeSize("Climatic",1,Double.MAX_VALUE,301);
	public static final AverageTradeSize UltraHigh = new AverageTradeSize("UltraHigh",1,300,201);
	public static final AverageTradeSize High = new AverageTradeSize("High",2,200,126);
	public static final AverageTradeSize Average = new AverageTradeSize("Average",3,125,76);
	public static final AverageTradeSize Low = new AverageTradeSize("Low",4,75,0);
	
	private static final AverageTradeSize[] averageTradeSizes = new AverageTradeSize[]{Climatic,UltraHigh,High,Average,Low};
	
	public static AverageTradeSize[] values(){
		return averageTradeSizes;
	}
	
	public static void analyze(List<Bar> barList,double[] atssma, int index, VsaBar vsaBar){
		if(barList == null || barList.isEmpty() || atssma == null || 0 == atssma.length || 
				index < 0 || index >= barList.size() || index >= atssma.length || vsaBar == null || atssma[index] == 0){
			return;
		}
		double percentage = barList.get(index).getAverageTradeSize()*100/atssma[index];
		for(AverageTradeSize averageTradeSize : AverageTradeSize.values()){
			if(percentage <= averageTradeSize.getUpperLimit() && percentage >= averageTradeSize.getLowerLimit()){
				vsaBar.setAverageTradeSize(averageTradeSize);
				break;
			}
		}
	}
	
	
	private AverageTradeSize(String name,int ordinal, double upperLimit,double lowerLimit){
		super(name,ordinal,upperLimit,lowerLimit);
	}
}
